package cc.cary.warehouse.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Cary
 * @date 2023/4/18
 */
@Configuration
public class SwaggerConfig {
    /**
     * 创建API
     */
    @Bean
    public OpenAPI springOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("工具类服务V1-API文档")
                        .description("嘿嘿嘿！！！")
                        .version("V1.0")
                        .license(new License().name("Cary").url("http://www.xx.com")))
                .externalDocs(new ExternalDocumentation()
                        .description("工具类服务V1-API文档！！！")
                        .url("http://www.xx.com"));
    }

    @Bean
    public GroupedOpenApi api_user() {
        return GroupedOpenApi.builder()
                .group("用户模块")
                .pathsToMatch("/v1/user/**")
                .build();
    }

    @Bean
    public GroupedOpenApi api_client() {
        return GroupedOpenApi.builder()
                .group("client模块")
                .pathsToMatch("/v1/client/**")
                .build();
    }

    @Bean
    public GroupedOpenApi api_default() {
        return GroupedOpenApi.builder()
                .group("默认")
                .packagesToScan("cc.cary.warehouse.controller")
                .build();
    }

}
